package com.js.mytransitiondemo.customize;

// Created by JS on 2021/7/7.

import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.util.Pair;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.js.mytransitiondemo.databinding.ActivityCarBinding;

public class CarActivity extends AppCompatActivity {

    private ActivityCarBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityCarBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.iv.setOnClickListener(v -> {
            Intent intent = new Intent(this, GarageActivityNew.class);
            transitionTo(intent, binding.iv);
        });
    }

    private void transitionTo(Intent intent, View iv) {
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this,
                new Pair<>(iv, "transition_home"));
        startActivity(intent, options.toBundle());
    }
}
